import { NextRequest, NextResponse } from 'next/server';
import { query } from '@/lib/sqlite_db';

export async function GET() {
  try {
    const sql = `
      SELECT id, serial_number, software_description, development_language, version, status, created_at
      FROM generation_record
      ORDER BY created_at DESC
      LIMIT 50
    `;
    const records = await query(sql);
    
    return NextResponse.json({ data: records });
  } catch (error) {
    console.error('获取生成记录失败:', error);
    return NextResponse.json({ data: [], error: '获取记录失败' }, { status: 500 });
  }
}